class Loading {
    static getInstance() {
        if (!Loading.Instance) {
            Loading.Instance = new Loading();
        }
        return Loading.Instance;
    }
    constructor() {
        this.init()
    }

    show() {
        this.el.style.display = 'flex';
    }

    hide() {
        this.el.style.display = 'none';
    }

    init() {
        this.el = document.createElement('div');
        this.el.innerText = 'Loading...'
        const sty = {
            'z-index': '9999',
            'position': 'fixed',
            // 'inset': '0px', //full screen Safari不支持
            'top': '0',
            'right': '0',
            'bottom': '0',
            'left': '0',
            'background': 'rgba(0,0,0,.3)',
            'color': 'white',
            'justify-content': 'center',
            'align-items': 'center',
            'display': 'none',
        }
        for (const key in sty) {
            if (Object.hasOwnProperty.call(sty, key)) {
                const element = sty[key];
                this.el.style[key] = element
            }
        }
        document.body.appendChild(this.el);
    }
}
export default Loading.getInstance()